package com.example.data0306.Adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.example.data0306.base.BaseVpAdapter;
import com.example.data0306.bean.NewsTypeBean;
import com.example.data0306.news.CompetitionFragment;
import com.example.data0306.news.NewContentFragment;
import com.example.data0306.news.YundingFragment;

public class NewTopAdapter extends BaseVpAdapter<NewsTypeBean> {
    public NewTopAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @Override
    protected Fragment createFragment(int position) {
        Fragment fragment = null;
        NewsTypeBean bean = (NewsTypeBean) getData(position);
        if (bean.getType() == NewsTypeBean.TYPE_ARTICLE) {
            fragment = new NewContentFragment();
        }else if(bean.getType() == NewsTypeBean.TYPE_SAISHI){
            fragment = new CompetitionFragment();
        }else if(bean.getType() == NewsTypeBean.TYPE_YUNDING){
            fragment = new YundingFragment();
        }
        return fragment;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return getData(position).getTitle();
    }
}
